{
  "location": "North Europe",
  "properties": {
    "sku": {
      "name": "standard"
    },
    "eventsOutOfOrderPolicy": "drop",
    "eventsOutOfOrderMaxDelayInSeconds": 10,
    "Inputs": [
      {
        "Name": "eventhubs",
        "Properties": {
          "DataSource": {
            "Properties": {
              "ConsumerGroupName": "streamanalytics",
              "EventHubName": "fieldhub",
              "ServiceBusNamespace": "btugiot",
              "SharedAccessPolicyKey": "TO_REPLACE",
              "SharedAccessPolicyName": "RootManageSharedAccessKey"
            },
            "Type": "Microsoft.ServiceBus/EventHub"
          },
          "Serialization": {
            "Properties": {
              "Encoding": "UTF8",
              "Format": null
            },
            "Type": "Json"
          },
          "Type": "Stream"
        }
      }
    ],
    "Transformation": {
      "Name": "btugiot",
      "Properties": {
        "Query": "WITH [Input] AS (\r\n    SELECT *\r\n    FROM [eventhubs] TIMESTAMP BY CreatedDateTime\r\n)\r\n\r\nSELECT \r\n    * \r\nINTO \r\n    [machinelearning] \r\nFROM \r\n    [Input];\r\n\r\nSELECT \r\n    ShipName, EngineName, AVG(Temperature), System.TimeStamp AS LogTime\r\nINTO \r\n    [queueAverageTemperature] \r\nFROM \r\n    [Input]\r\nGROUP BY\r\n    ShipName, EngineName, TumblingWindow(minute, 1);\r\n\r\nSELECT \r\nShipName, EngineName, Temperature, CreatedDateTime \r\nINTO \r\n    [queueHighTemperature] \r\nFROM \r\n    [Input]\r\nWHERE\r\n    Warning = 1",
        "StreamingUnits": 1
      }
    },
    "Outputs": [
      {
        "Name": "machinelearning",
        "Properties": {
          "DataSource": {
            "Properties": {
              "Container": "machinelearning",
              "DateFormat": "yyyy/MM/dd",
              "PathPattern": "",
              "StorageAccounts": [
                {
                  "AccountKey": "TO_REPLACE", 
                  "AccountName": "btugiot"
                }
              ],
              "TimeFormat": "HH"
            },
            "Type": "Microsoft.Storage/Blob"
          },
          "Serialization": {
            "Properties": {
              "Encoding": "UTF8",
              "FieldDelimiter": ","
            },
            "Type": "Csv"
          }
        }
      },
      {
        "Name": "queueAverageTemperature",
        "Properties": {
          "DataSource": {
            "Properties": {
              "QueueName": "averagetemperature",
              "ServiceBusNamespace": "btugiot",
              "SharedAccessPolicyKey": "TO_REPLACE",
              "SharedAccessPolicyName": "RootManageSharedAccessKey"
            },
            "Type": "Microsoft.ServiceBus/Queue"
          },
          "Serialization": {
            "Properties": {
              "Encoding": "UTF8",
              "Format": "LineSeparated"
            },
            "Type": "Json"
          }
        }
      },
      {
        "Name": "queueHighTemperature",
        "Properties": {
          "DataSource": {
            "Properties": {
              "QueueName": "hightemperature",
              "ServiceBusNamespace": "btugiot",
              "SharedAccessPolicyKey": "TO_REPLACE",
              "SharedAccessPolicyName": "RootManageSharedAccessKey"
            },
            "Type": "Microsoft.ServiceBus/Queue"
          },
          "Serialization": {
            "Properties": {
              "Encoding": "UTF8",
              "Format": "LineSeparated"
            },
            "Type": "Json"
          }
        }
      }
    ]
  }
}